<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>将字符串分割成小块</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.chunk-split" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">chunk_split</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">chunk_split</span> &mdash; <span class="dc-title">将字符串分割成小块</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.chunk-split-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>chunk_split</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$body</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$chunklen</code><span class="initializer"> = 76</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$end</code><span class="initializer"> = &quot;\r\n&quot;</span></span>
  ]] ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   使用此函数将字符串分割成小块非常有用。例如将
   <span class="function"><a href="base64_encode.html" class="function">base64_encode()</a></span> 的输出转换成符合 RFC 2045 语义的字符串。它会在每
   <code class="parameter">chunklen</code> 个字符后边插入
   <code class="parameter">end</code>。
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.chunk-split-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">body</code></dt>

     <dd>

      <p class="para">
       要分割的字符。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">chunklen</code></dt>

     <dd>

      <p class="para">
       分割的尺寸。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">end</code></dt>

     <dd>

      <p class="para">
       行尾序列符号。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.chunk-split-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回分割后的字符。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.chunk-split-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5894">
    <p><strong>Example #1 <span class="function"><strong>chunk_split()</strong></span>  例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;使用&nbsp;RFC&nbsp;2045&nbsp;语义格式化&nbsp;$data<br /></span><span style="color: #0000BB">$new_string&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">chunk_split</span><span style="color: #007700">(</span><span style="color: #0000BB">base64_encode</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.chunk-split-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="str_split.html" class="function" rel="rdfs-seeAlso">str_split()</a> - 将字符串转换为数组</span></li>
    <li class="member"><span class="function"><a href="explode.html" class="function" rel="rdfs-seeAlso">explode()</a> - 使用一个字符串分割另一个字符串</span></li>
    <li class="member"><span class="function"><a href="split.html" class="function" rel="rdfs-seeAlso">split()</a> - 用正则表达式将字符串分割到数组中</span></li>
    <li class="member"><span class="function"><a href="wordwrap.html" class="function" rel="rdfs-seeAlso">wordwrap()</a> - 打断字符串为指定数量的字串</span></li>
    <li class="member"><a href="http://www.faqs.org/rfcs/rfc2045" class="link external">&raquo;&nbsp;RFC 2045</a></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>